# -*- coding: utf-8 -*-

import random
import string
import hashlib

from .common import now_ts


class Random(object):
    digitals = string.digits
    alphanum = string.ascii_letters + string.digits

    @classmethod
    def string(cls, length=16):
        return ''.join(random.sample(cls.alphanum, length))

    @classmethod
    def integer(cls, length=10):
        return int(''.join(random.sample(cls.digitals, length)))

    @classmethod
    def filename(cls, *args):
        seed = ''.join(args)
        seed += str(now_ts())
        return hashlib.md5(seed.encode('utf8')).hexdigest()
